# coding=utf-8
"""
Author: Mr.夏末
@Function: 选择排序
"""
height = [155, 160, 165, 170, 175, 180, 185, 190, 165, 175, 180]
# 剩下一个元素了不用比较了
for j in range(len(height) - 1):
    # 找到最大的，记录下标
    maxindex = 0
    # 每一轮少比一个，-j
    for i in range(1, len(height) - j):
        # 如果当前元素比最大值大，就记录当前元素下标
        if height[i] > height[maxindex]:
            maxindex = i
    # print(maxindex)
    # 交换到末尾
    # 最后一个元素下标也要-j
    height[maxindex], height[len(height) - 1 - j] = height[len(height) - 1 - j], height[maxindex]
print(height)

print("------------------------------------------------------------------------------------------")

weight = [155, 160, 165, 170, 175, 180, 185, 190, 150, 165, 175, 180]
gi = 0
while gi < len(weight) - 1:
    kmax = 0
    ki = 1
    while ki < len(weight) - gi:
        if weight[ki] > weight[kmax]:
            kmax = ki
        ki += 1
    weight[kmax], weight[len(weight) - 1 - gi] = weight[len(weight) - 1 - gi], weight[kmax]
    gi += 1
print(weight)
